// JavaScript Document
var Base={
	getStyle:function(obj){
		if(obj.currentStyle){
			return obj.currentStyle
		}else{
			return getComputedStyle(obj,false)	
		}	
	},
	getstyle:function(obj,attr){
		if(obj.currentStyle){
			return obj.currentStyle[attr]
		}else{
			return getComputedStyle(obj,false)[attr]	
		}		
	},
	startMove:function(obj,json,fn){
		//{key:value}
		clearInterval(obj.timer)
		obj.timer=setInterval(function(){
			for(var attr in json){
				//attr=left
				//获取初始值
				if(attr=='opacity'){
					var iCur=parseInt(parseFloat(Base.getstyle(obj,attr))*100)
				}else{
					var iCur=parseInt(Base.getstyle(obj,attr))
					
				}
				//计算速度
				var speed=(json[attr]-iCur)/6
				speed=speed >0 ? Math.ceil(speed) : Math.floor(speed);
				if(json[attr]==iCur){
					clearInterval(obj.timer);
					if(fn){
						fn()	
					}
				}else{
					if (attr == 'opacity') {
						obj.style.filter = 'alpha(opacity' + iCur + speed + ')';
						obj.style.opacity = (iCur + speed) / 100;
					} else {
						obj.style[attr] = (iCur + speed) + 'px';
					}
				}
			}
		},50)
	}
}
//封装日期工具
var TimeUtil={
	//判断是否为闰年 能被4整除但是不能被100整除，或者能被四百整除
	isLeapYear:function(year){
		if(year%4==0 && year%100!=0 || year%400==0){
			return true;	
		}else{
			return false;	
		}
	},
	//字符串转日期对象
	paserStr:function(date,separator){
		var time=date.split(separator);
		time=time.join("-");
		time=Date.parse(time);
		return new Date(time)
	},
	//获得某个月份的天数
	getMonthDay:function(m){
		m=parseInt(m)
		switch(m){
			case 1:
			case 3:
			case 5:
			case 7:
			case 8:
			case 10:
			case 12:return 31;break;
			case 2:return 28;break;
			case 4:
			case 6:
			case 9:
			case 11:return 30;break;
		}
	},
	//获得两个日期直接相差的天数
	getDiff:function(date1,date2){
		var time1=date1.getTime();
		var time2=date2.getTime();
		return Math.floor(Math.abs(time1-time2)/(1000*3600*24))
	},
	//获得N天以后的日期
	getSday:function(n){
		var now=new Date();
		now=now.getTime();
		now+=n*1000*3600*24;
		return new Date(now)
	}
}